package com.mm.service.impl;

import com.mm.dao.BillMapper;
import com.mm.model.Bill;
import com.mm.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 账单service实现类
 *
 * @date 2018/7/18 19:26
 */
@Service(value = "billService")
public class BillServiceImpl implements BillService{
	@Autowired
	private BillMapper billMapper;

	/**
	 * 保存账单
	 *
	 * @param bill Bill
	 */
	@Override
	public void saveBill(Bill bill) {
		bill.setAddTime(System.currentTimeMillis());
		billMapper.insertBill(bill);
	}

	/**
	 * 更新账单
	 *
	 * @param bill Bill
	 */
	@Override
	public void updateBill(Bill bill) {
		if (bill != null) {
			billMapper.updateBillById(bill);
		}
	}

	/**
	 * 获取账单
	 *
	 * @param billId 账单ID
	 * @return Bill
	 */
	@Override
	public Bill getOneBillById(Long billId) {
		if (billId == null) {
			return null;
		}
		return billMapper.getOneBillById(billId);
	}

	/**
	 * 通过账单ID删除账单
	 *
	 * @param billId 账单ID
	 */
	@Override
	public void deleteBillById(Long billId) {
		if (billId != null) {

		}
		billMapper.deleteBillById(billId);
	}
}
